package bookstudytest.threadtest.lock;

public class Lock {
    private boolean lock = false;
    public synchronized void getLock() throws InterruptedException {
        while (lock){
            wait();
        }
        lock =true;
    }

    public synchronized void unlock (){
        System.out.println("释放锁");
        lock = false;
        notify();
    }


}
